﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Core.Graphics;

namespace WorldEditor.Tiles
{
    public partial class PickATile : UserControl
    {
        public event EventHandler SelectedTileChanged;
        public event EventHandler TileClicked;

        public TileSetTile Tile
        {
            get {
                if (_Tile == null) { return TileSetTile.BlankTile; }

                return _Tile;
            }
            set
            {
                 _Tile = value;
                 if (value != null)
                 {                   
                    //Get Image and load it in
                    pbTile.Image = TileSetTileBitmaps.GetTileBitmap(value.SpriteID, TileSetTypes.Terrain);

                    if (SelectedTileChanged != null)
                        SelectedTileChanged.Invoke(value, EventArgs.Empty);
                 }
            }
        }

        protected TileSetTile _Tile = null;
        public PickATile()
        {
            InitializeComponent();
        }

        private void pbTile_Click(object sender, EventArgs e)
        {
            if (TileClicked != null)
            {
                TileClicked.Invoke(this, EventArgs.Empty);
            }            
        }
    }
}
